package com.wyj.wuliwuli.service.impl;

import com.wyj.wuliwuli.common.AjaxRequest;
import com.wyj.wuliwuli.common.AjaxResult;
import com.wyj.wuliwuli.common.PageParam;
import com.wyj.wuliwuli.entity.WuliFeedback;
import com.wyj.wuliwuli.entity.mapper.WuliFeedbackMapper;
import com.wyj.wuliwuli.service.WuliFeedbackService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * @Version 1.0
 * @Description
 */
@Service
@RequiredArgsConstructor
public class WuliFeedbackServiceImpl implements WuliFeedbackService {

    private final WuliFeedbackMapper wuliFeedbackMapper;

    /**
     * 分页查询
     *
     * @param ajaxRequest
     * @return
     */
    @Override
    public AjaxResult page(AjaxRequest<PageParam> ajaxRequest) {
        PageParam pageParam = ajaxRequest.getData();
        Pageable pageable = PageRequest.of(pageParam.getPageNum(), pageParam.getPageSize(), pageParam.getDirection(), pageParam.getProperty());
        Page<WuliFeedback> page = wuliFeedbackMapper.findAll(pageable);
        return AjaxResult.ok(page);
    }

    /**
     * 根据ID查询
     *
     * @param id 通知ID
     * @return
     */
    @Override
    public AjaxResult getById(Long id) {
        WuliFeedback feedback = wuliFeedbackMapper.getById(id);
        return AjaxResult.ok(feedback);
    }
}
